home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: why not add getch() to the std C RTL?
- Date: 4 Feb 1996 09:16:25 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4f2pl9INNmmm@keats.ugrad.cs.ubc.ca>
- References: <DM85L8.5Jn@emr1.emr.ca> <bnelsonDM887t.LDI@netcom.com>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <bnelsonDM887t.LDI@netcom.com>,
- Bob Nelson <bnelson@netcom.com> wrote:
- >On Sun, 4 Feb 1996 00:05:32 GMT, John Grant wrote:
- >
- >> There are *many* people who want to do the following in their C programs:
- >> - read a single unbuffered keystroke (getch() in DOS, ioctl in unix...)
- >
- >> The usual response is "not standard C, o/s-specific" etc.
- >
- >I'll just quote the following from "Expert C Programming" by Peter van
- >der Linden (ISBN 0-13-177429-8) and offer no comments of my own, other
- >than some emphasis added. Instead, it'll be interesting to see how
- >participants in comp.lang.c respond to what PvdL thinks (especially in
- >the context of your posting). Here's the paragraph from page 213:
- >
- >"People often wonder why ANSI C didn't define a standard function to
- >get a character if a key has been pressed. Without a standard
- >function, every system has a different method and program portability
- >is lost. The argument against providing kbhit() as part of the
- >standard is that *it is mostly useful for GAMES software* and there
- >are many other terminal I/O features that are not standardized. In
- >addition, you don't want to promise a standard library function *that
- >SOME OS's will find difficult to provide.* The argument for providing
- >it is that it is mostly useful for games software and that games
- >writers don't need the myriad of other terminal I/O features that
- >could be standardized. Whichever view you hold, it's true the XJ311
- >missed an opportunity to reinforce C as the language of choice for a
- >generation of programmers writings games on UNIX."
- >
- >Comments?
-
- More comments:
-
- Suppose kbhit() were part of the standard. That's not enough to encourage game
- programming. You also want, even for text-based games, full-screen control.
- Implementing kbhit() is trivial compared to terminal control. Including
- curses-like functionality in the standard would bloat it immensely with
- functions that are irrelevant for most people.
-
- This lack did not stop that "generation of game programmers". Instead, they
- poured back some brewski's and developed the BSD curses library which, by the
- mid 80's, AT&T snatched to develop a more powerful version for AT&T UNIX.
-
- Furthermore, kbhit() is obsoleted with the advent of graphics, which is what
- game programmers are ultimately interested in. Is kbhit() still used under
- Microsoft Windows? X11 doesn't use it; an X program receives events, some of
- which can be keypress and keyrelease events---which gives you far more general
- semantics that are akin to the PC's "scan codes". An X11 game can sense that a
- key is held down independently of other keys, in a standard manner that works
- on all X terminals.
-
- (Check out the controls for xpilots---idependent firing, rotation, thrust and
- shields and other commands).
-
- This is not something you can do having only the functionality of kbhit().
- In fact, it's not even possible with ordinary terminal I/O, unless you have a
- special terminal that can pass you press/release codes.
- --
-
-